DROP TABLE IF EXISTS user_;
CREATE TABLE user_ (
	user_id bigint(20) NOT NULL AUTO_INCREMENT,
  	email varchar(255) DEFAULT NULL,
  	username varchar(255) DEFAULT NULL,
  	password varchar(255) DEFAULT NULL,
  	first_name varchar(255) DEFAULT NULL,
  	last_name varchar(255) DEFAULT NULL,
 	gender varchar(6) DEFAULT NULL,
	create_date datetime DEFAULT NULL,
	portrait varchar(100) DEFAULT NULL,
 	website varchar(255) DEFAULT NULL,
 	about_me varchar(500) DEFAULT NULL,
	dob date DEFAULT NULL,
	status_ int(3) DEFAULT '1' COMMENT '0：已激活，1：未激活，2：已删除',
  	PRIMARY KEY (user_id)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;

BEGIN;
INSERT INTO user_ VALUES ('15', 'zizibj@hotmail.com', 'zizibj', 'e3e93b60bd722ced25a041f65afd4e396e2bafe57e0c3de0c8b6b0aa8b054506', null, null, null, '2011-11-20 15:32:02', null, null, null, null, '0');
COMMIT;


DROP TABLE IF EXISTS topic;
CREATE TABLE topic (
	topic_id bigint(20) NOT NULL AUTO_INCREMENT,
	title varchar(150) DEFAULT NULL,
	content longtext DEFAULT NULL,
	user_id bigint(20) DEFAULT NULL,
	create_date datetime DEFAULT NULL,
	modified_date datetime DEFAULT NULL,
  	PRIMARY KEY (topic_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS comment_;
CREATE TABLE comment_ (
	comment_id bigint(20) NOT NULL AUTO_INCREMENT,
	topic_id bigint(20) DEFAULT NULL,
	user_id bigint(20) DEFAULT NULL,
	content varchar(255) DEFAULT NULL,
	parent_id bigint(20) DEFAULT NULL,
	create_date datetime DEFAULT NULL,
	close_status bit(1) DEFAULT NULL,
  	PRIMARY KEY (comment_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS ticket;
CREATE TABLE ticket (
	ticket_id bigint(20) NOT NULL AUTO_INCREMENT,
	key_ varchar(75) DEFAULT NULL,
	class_name_id bigint(20) DEFAULT NULL,
	class_pk bigint(20) DEFAULT NULL,
	create_date datetime DEFAULT NULL,
	expiration_date datetime DEFAULT NULL,
	category varchar(75) DEFAULT NULL,
  	PRIMARY KEY (ticket_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS class_name;
CREATE TABLE class_name (
	class_name_id bigint(20) NOT NULL AUTO_INCREMENT,
	value_ varchar(200) DEFAULT NULL,
  	PRIMARY KEY (class_name_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS role_;
CREATE TABLE role_ (
	role_id bigint(20) NOT NULL AUTO_INCREMENT,
	name varchar(75) DEFAULT NULL UNIQUE,
	description varchar(200) DEFAULT NULL,
  	PRIMARY KEY (role_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

BEGIN;
INSERT INTO role_ VALUES ('1', 'administrator', 'Administrators are super users who can do anything.');
COMMIT;


DROP TABLE IF EXISTS user_role;
CREATE TABLE user_role (
  	user_id bigint(20) NOT NULL DEFAULT '0',
  	role_id bigint(20) NOT NULL DEFAULT '0',
  	PRIMARY KEY (user_id, role_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

BEGIN;
INSERT INTO `user_role` VALUES ('15', '1');
COMMIT;
